package com.societyGames.faceExercises
{
	import com.societyGames.action.ActionQueue;
	import com.societyGames.action.CallbackAction;
	import com.societyGames.action.DelayAction;
	import com.societyGames.system.EventObject;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextLineMetrics;

	public class FaceRender extends Sprite
	{
		private var _actionsCompleteEventObject:EventObject;
		private var _faceSimulation:FaceSimulation;
		private var _actionQueue:ActionQueue;
		
		public function FaceRender(faceSimulation:FaceSimulation, actionQueue:ActionQueue)
		{
			this._actionsCompleteEventObject = new EventObject(this, "ACTIONS_COMPLETE");
			this._faceSimulation = faceSimulation;
			this._actionQueue = actionQueue;
		}
		
		public function get actionsCompleteEventObject():EventObject
		{
			return this._actionsCompleteEventObject;
		}
		
		//Tell the renderer that the game is over and let us know when animations are complete.
		public function complete():void
		{
			this._actionQueue.add(new DelayAction(2000));
			this._actionQueue.add(new CallbackAction(actionsCompleteCallback));
		}
		
		private function actionsCompleteCallback():void
		{
			this._actionsCompleteEventObject.dispatchEvent();
		}
	}
}